1. Technical Field
The present invention relates to preloading pages, and more particularly, to a method and system for preloading a page using a control flow.
2. Discussion of the Related Art
Conventional computing systems include main memory (e.g., random access memory), which can operate at high speed but can store only a small amount of information. An auxiliary storage device (e.g., a hard disk drive) can store a large amount of information but operates at a relatively low speed. A virtual memory space compensates for the limited storage space of main memory by mapping memory of the auxiliary storage device to be used as main memory.
A central processing unit (CPU) does not directly access information in the auxiliary storage device but accesses information in the main memory, and therefore, an operating system (OS) loads code of a program corresponding to a process handled by the CPU from the auxiliary storage device into the main memory. However, due to a capacity difference between the main memory and the auxiliary storage device, all of the program code corresponding to the process handled by the CPU cannot be loaded into the main memory at the same time. Accordingly, the OS loads only essential code in the main memory. When necessary code does not exist in the main memory, a page fault is generated and a necessary page is loaded from the auxiliary storage device into the main memory. In addition, the OS may perform a preload in which code to be executed by the CPU is predicted and loaded in advance.
Excessive overhead is encountered when accessing the auxiliary storage device operating at low speed. Accordingly, the number of page faults significantly affects system performance. An exact preload reduces the number of page faults.
FIG. 1 is a flowchart illustrating a path in which a program is executed. FIG. 2 illustrates an order in which code is generated when the program illustrated in FIG. 1 is compiled.
Referring to FIGS. 1 and 2, blocks A, B, C, D, E, F, G, and H illustrated in FIG. 1 may indicate code of the program, which is defined by functions. As illustrated in FIG. 1, a plurality of program execution paths may exist. For instance, there may be a path having an order of A, B, C, D, G, and A, a path having an order of A, B, E, F, G, and A, and a path having an order of A, B, E, H, G, and A. A compiler compiles the program, and compiled code may be stored in memory for storing code, for example, an auxiliary storage device (e.g., flash memory or a hard disk drive). When the program is most frequently executed in the path having the order of A, B, C, D, G, and A among the program execution paths, the compiler may store the compiled code in the auxiliary storage device in the order illustrated in FIG. 2.
A demand paging module (DPM) included in the OS may perform the preload. Usually, code can be preloaded based on code locality within the program
The DPM can perform the preload using the locality when the program code is stored in the order as illustrated in FIG. 2. At this time, the code A should be executed after the code G is executed, but the DPM preloads the code E. Since the DPM cannot have information about which code is executed after the code G is executed, it performs the preload based on the locality. As a result, a page fault occurs. When the page fault occurs, program execution time is increased.